date = 15/5/01
changed parameters to pParameters

date = 19/4/2001
ensured that duration does not go negative

added property pMyName : ""

added

added on getParametersAsSpreadsheetText(labelText)

return labelText & " maxreversals", maxreversals of parameters, ¬

labelText & " maxtrials", maxtrials of parameters, ¬

labelText & " stepSize", stepSize of parameters, ¬

labelText & " initialDuration", initialDuration of parameters
end getParametersAsSpreadsheetText

Scoll down for a worked example
--
usage: 

--1. Create a staircase with starting parameters

set yourStairCaseName to load script file ("" & Psyscript base folder & "libraries:stairCase library")
                         tell yourStairCaseName to initialize(maxreversals:10, maxtrials:20, stepSize:4, initialDuration:40)

--2. Start your trial loop

 

Update the staircase after each trial

update(gradedResponse) --0 for wrong, 1 for correct

As necessary, update the stepSize

updateStepSize(newStep)

 3. Get data with:

getRecord()

-->stairCaseRecord

getParameters()

 
-->parameters

completed()

-->true/false

--nb: handlers that begin with "i" are for internal use of the object

--you should not be calling them

EXAMPLE
tell application "PsyScript"

activate

begin experiment

set startingParameters to maxreversals:10, maxtrials:20, stepSize:4, initialDuration:40
      set myStairCase to load script file ("" & Psyscript base folder & "libraries:stairCase library")
      tell myStairCase to initialize(startingParameters)

set myStairCase to my createStairCase(startingParameters)

set goodResponse to "Z"

set completed to false

set myDuration to initialDuration of startingParameters

repeat while not completed

do trial "!e  + #100 !e 'duration  = ?1 screen refreshes' !v?1 'Push ’z‘ to get this correct, any other to get it wrong'  !t(2000)" given myDuration

if (subject response = goodResponse) then

set gradedResponse to 1

else

set gradedResponse to 0

end if

set myDuration to update(gradedResponse) of myStairCase

set completed to completed() of myStairCase

end repeat

display dialog "that took" & trialCount of getRecord() of myStairCase

end experiment
end tell
return getRecord() of myStairCase, getParameters() of myStairCase